import javax.swing.plaf.SpinnerUI;

class WashMachine2 {//类名大驼峰
    //成员属性/字段：   定义在类里面 方法外面
    public String brand;
    public String type;
    public double weight;
    public double length;
    public double width;
    public double height;
    public String color;//成员变量全局变量
    public void func() {
        int a = 10;//局部变量
    }

    //成员行为/方法
    public void washClothes() {//方法名小驼峰
        System.out.println("洗衣功能");;
    }
    public void dryClothes() {
        System.out.println("脱水功能");
    }
}
class Dog {
    public String name;
    public int age;
    public String color;
    public void eat() {
        System.out.println(name+"吃饭");
    }
    public void bark() {
        System.out.println(name+"汪汪叫");
    }
}
public class LeiDuiXiang {
    public static void main(String[] args) {
        //通过new关键字 实例化了一个Dog的对象
        Dog dog = new Dog();//dog是创建的一个似复刻变量
        dog.name = "初一";//访问似复刻变量它里面的复制变量
        dog.age = 10;
        dog.color = "黄色";
        System.out.println(dog.name);
        System.out.println(dog.age);
        System.out.println(dog.color);
        dog.eat();
        dog.bark();

        System.out.println("===================");

        Dog dog2 = new Dog();
        //dog2是一个引用变量似复刻变量，里面存哈希值，指向dog2对象空间
        dog2.name = "初二";
        dog2.age = 12;
        dog2.color = "黄色2";
        System.out.println(dog2.name);
        System.out.println(dog2.age);
        System.out.println(dog2.color);
        dog2.eat();
        dog2.bark();
    }
}

class Date2 {
    public int year;
    public int month;
    public int day;

    public void setDate(/*Date2 this,*/int year,int month,int day) {
        this.year = year;
        this.month = month;
        this.day = day;
    }
    public void printfDate() {
        System.out.println("年："+this.year+"月：" +
                this.month+"日："+this.day);//每个单位拿到取过来拼接的，单位有字符串单位、非字符串数据单位
    }

    public static void main(String[] args) {
        Date2 date = new Date2();
        date.setDate(2008,8,8);
        date.printfDate();
        System.out.println("=====================");
        Date2 date2 = new Date2();
        date2.setDate(2000,9,9);
        date2.printfDate();
    }
}

class Student2 {
    //成员变量：定义在类的内部，方法的外部，全局

    //普通成员变量/实例成员变量
    private String name;
    private int age;
    //静态成员变量
    public static String classRoom;


    //代码块
    {//非静态代码块
        this.name = "zhangsan";//初始化复制变量的内容
        this.age = 19;
        System.out.println("实例代码块");
    }
    static {//静态代码块
        classRoom = "109";
        System.out.println("静态代码块1");
    }
    static {
        classRoom = "888";
        System.out.println("静态代码块2");
    }


    //成员方法
    public Student2() {//构造方法没有返回值
        System.out.println("不带参数的构造方法");
    }
     Student2(String name) {//带参数的构造方法
       this.name = name;
    }
    public Student2(String name,int age) {//带参数的构造方法
        this.name = name;
        this.age = age;
    }

    public String getName() {//封装方法
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public int getAge() {
        return age;
    }
    public void setAge(int age) {
        this.age = age;
    }

    public void eat() {
        System.out.println(this.name+"正在吃饭");
        this.show();//都行
        show();
    }
    public void show() {
        System.out.println("姓名："+this.name+"年龄："+this.age);
    }
    public String toString() {
        return "姓名："+this.name+"年龄："+this.age;
    }
    public static void func() {
        System.out.println("这是一个静态方法");
        Student2 student = new Student2();
        student.show();
    }
}

class Test2 {
    public static void main2(String[] args) {
        Student2 student = new Student2();
        System.out.println(student);//不是打印似复刻变量的哈希值，而是调用了自己写的toString，重写方法了
        System.out.println("======================");
        Student2 student2 = new Student2();
        System.out.println("======================");
        Student2 student21 = new Student2();
        System.out.println("======================");
        Student2 student22 = new Student2();
        System.out.println();
    }




    public int add(int a,int b) {
        return a + b;
    }

    public static void main3(String[] args) {
        Test2 test = new Test2();
        System.out.println(test.add(1,2));

        Student2 student = new Student2();
        student.classRoom = "109";
        Student2.classRoom = "108";
        System.out.println(student.classRoom);
        System.out.println(Student2.classRoom);
    }

    public static void main(String[] args) {
        Student2 student = new Student2();//似复刻变量也是局部变量
        student.setName("zhangfei");//成员变量name被private修饰，得通过封装好的方法来间接访问它
        System.out.println(student.getName()); //构造方法的重载
        Student2 student2 = new Student2("zhangfei,99");
    }
}




